import { useEffect, useState } from "react";

export function useWinSize() {
  const [size, setSize] = useState({
    w: window.innerWidth,
    h: window.innerHeight
  });
  function onResize() {
    setSize({ w: window.innerWidth, h: window.innerHeight });
  }

  useEffect(() => {
    window.addEventListener("resize", onResize);
    return () => window.removeEventListener("resize", onResize);
  }, []);
  return size;
}
